{template head}
<script type="text/javascript" src="{STATICDIR}third/plupload/plupload.full.min.js"></script>
<script type="text/javascript">
function submitcheck()
{
	return true;
}

function saveInfo()
{
	if(!submitcheck())
	{
		return;
	}
	var url = '{SITE_URL}ajax/index.php?m=saveGuanggao';
	
	var data = $('#savedata').serialize();
		
	var callback = function(data)
	{
		if(data.sign == -2)
		{
			window.location = data.url;
		}
		else
		{
			if(data.sign == 1)
			{
				//添加成功,返回列表页
				layer.alert(data.msg,function(){
					window.location = $('#gotoList').attr('href');
				});
			}
			else
			{
				if(data.msg)
				{
					layer.msg(data.msg);
				}
				else
				{
					layer.msg('操作失败');
				}
			}
		}
	};
	makeAjax('post',url,data,callback);
}

</script>
<body>
<div class="wrapper">
	<div class="crumbs"><span style="margin: 0 5px;color: #333;font-size: 14px;">{$fTitle}</span> &gt; <a id="gotoList" href="{SITE_URL}index.php?a=guanggaoM&m={$parm[type]}">{$sTitle}</a> &gt; <span>{$pagetitle}</span><a style="float:right;font-size:13px;" href="javascript:history.go(-1);">返回</a></div>
	
	<div class="container_tit clearfix mb20 ft14">
	
	<form id="savedata">
		<input type="hidden" name="id" value="{$guanggao[id]}" />
		<input type="hidden" name="type" value="{$parm[type]}" />
		<h2 class="form_tit">
			{$type}端的Banner信息
		</h2>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">序号(排序)：</label>
				<input  type="text" id="sort" name="sort" value="{$guanggao[sort]}" class="text w130" />
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">标题：</label>
				<input  type="text" id="title" name="title" value="{$guanggao[title]}" class="text w340" />
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">{$type}图上传：</label>
				<a id="btn1" href="javascript:;" class="btnyellow mr15">上传图片</a>
			</p>
			<p class="clearfix" style="padding-top: 10px;">
				<label class="name"></label>
				{if !empty($guanggao[tupian])}
					<img id="img_logo" src="{OSS_URL}{$guanggao[tupian]}"  style="max-width: 350px;height: 200px;" />
				{else}
					<img id="img_logo" src=""  style="max-width: 350px;height: 200px;" />
				{/if}
				<input type="hidden" id="logo" name="tupian" value="{$guanggao[tupian]}" />
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">{$type}链接地址：</label>
				<input placeholder="图片链接地址" type="text" id="url" name="url" value="{$guanggao[url]}" class="text w340" />
			</p>
		</div>
		
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">起止时间：</label>
				<input type="text" class="w200 text" style="width:200px;" class="text" format='date' name='start' id="start" value="{php echo time_formart($guanggao['start'],1)}" placeholder="请输入日期">
				<span>至</span>
				<input type="text" class="mr15 w200 text" style="width:200px;" class="text" format='date' name='end' id="end" value="{php echo time_formart($guanggao['end'],1)}" placeholder="请输入日期">
			</p>
		</div>
		<div class="form_item clearfix">
			<p class="clearfix" style="height: 28px;line-height: 28px;">
				<label class="name">是否启用：</label>
				<input style="vertical-align: middle;" {if $pingtai['status'] == '1' || empty($pingtai['status'])}checked{/if} class="checkbox" type="radio" name="status" value="1" />
				<label for="resort_index" class="mr15">禁用</label>
				<input style="vertical-align: middle;" {if $pingtai['status'] == '2'}checked{/if} class="checkbox" type="radio" name="status" value="2" />
				<label for="resort_index">启用</label>
			</p>
		</div>
        <div class="form_item clearfix" style="padding-top: 20px;>
			<p class="clearfix">
			    <input type="button" class="btnblue" value="提交" onclick="saveInfo();" />
			</p>
		</div>
    </form>
    </div>
</div>
<script>
	var uploader = new plupload.Uploader({//创建实例的构造方法
        runtimes: 'html5,flash,silverlight,html4', //上传插件初始化选用那种方式的优先级顺序
        browse_button: 'btn1', // 上传按钮
        url: "{SITE_URL}ajax/object.php", //远程上传地址
        flash_swf_url: '{STATICDIR}plupload/Moxie.swf', //flash文件地址
        silverlight_xap_url: '{STATICDIR}plupload/Moxie.xap', //silverlight文件地址
        filters: {
            max_file_size: '2mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）
            mime_types: [//允许文件上传类型
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: false, //true:ctrl多文件上传, false 单文件上传
        init: {
            FilesAdded: function(up, files) { //文件上传前
                if ($("#ul_pics").children("li").length > 30) {
                    ts("您上传的图片太多了！");
                    uploader.destroy();
                } else {
                    var li = '';
                    plupload.each(files, function(file) { //遍历文件
                        li += "<li id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></li>";
                    });
                    $("#ul_pics").append(li);
                    uploader.start();
                }
            },
            UploadProgress: function(up, file) { //上传中，显示进度条
         var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function(up, file, info) { //文件上传成功的时候触发
	               var data = eval("(" + info.response + ")");
	               
	                var picurl = '{OSS_URL}';
	                $("#img_logo").attr('src',picurl+data.name);
	                $("#logo").val(data.name);
	              //  _upload_callback(data.name,data.size);
	            },
            Error: function(up, err) { //上传出错的时候触发
                layer.msg(err.message);
            },
            UploadComplete:function()
            {
            	layer.msg('上传成功');

            	//window.location = window.location;
            }
        }
    });
    uploader.init();
</script>
{template foot}